import { slugToTitle, optionallyAddLeadingSlash } from '@mintlify/common';
export const generateDecoratedMintNavigationFromPages = (filenamePageMetadataMap, mintConfigNav) => {
    const createNav = (nav) => {
        return {
            ...nav,
            pages: nav.pages.map((page) => {
                if (typeof page === 'string') {
                    const pageMetadata = filenamePageMetadataMap[page];
                    if (pageMetadata) {
                        return pageMetadata;
                    }
                    else {
                        console.log(`⚠️   "${page}" is defined in the mint.json navigation but the file does not exist.`);
                        return {
                            title: slugToTitle(page),
                            href: optionallyAddLeadingSlash(page),
                        };
                    }
                }
                return createNav(page);
            }),
        };
    };
    return mintConfigNav.map((nav) => createNav(nav));
};
